//
// Created by yangchao on 2022/7/14.
// 1047. 删除字符串中的所有相邻重复项 : https://leetcode.cn/problems/remove-all-adjacent-duplicates-in-string/
//

#include <string>
using namespace std;

class RemoveDuplicates {
public:
    string removeDuplicates(string s) {
        string stk;
        for (const auto &item : s) {
            if (!stk.empty() && stk.back() == item) {
                stk.pop_back();
            } else {
                stk.push_back(item);
            }
        }
        return stk;
    }
};

